<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:cc="http://xmlns.jcp.org/jsf/composite/ezcomp"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

    <body>
        <ui:composition template="./../WEB-INF/template/user/userPageTemplateWhitoutSidebar.xhtml">

            <ui:define name="title">
                Calendar #{otherUserHome.userEmail}
            </ui:define>




            <ui:define name="content">
                <h:form>
                    <p>
                        <h3 align="center">#{otherUserHome.otherUser.name} #{otherUserHome.otherUser.surname}'s MeteoCal</h3>
                    </p>
                </h:form>
                <h:form id="calendarForm">
                    <p:schedule id="calendar" styleClass="calendar-style" 
                                value="#{otherUserHome.eventModel}" 
                                widgetVar="myschedule" draggable="false"
                                timeFormat=""
                                ignoreTimezone="false"
                                >
                        <p:ajax event="eventSelect" listener="#{otherUserHome.onEventSelect}" update="eventSummary" oncomplete="PF('eventSummary').show();" />

                    </p:schedule>

                    <p:dialog widgetVar="eventSummary" id="eventSummary" >
                        <c:if test="#{not empty otherUserHome.selectedEvent and otherUserHome.selectedEvent.visibility}">
                            <p:outputPanel style="height: 450px;">
                                <h:outputLabel value="Title"  styleClass="bold-label"/> <br/>
                                <h:outputText value="#{otherUserHome.selectedEvent.title}"/>

                                <p>
                                    <h:outputLabel value="Description" styleClass="bold-label"/> <br/>
                                    <p:scrollPanel mode="native" style="width:350px;height:200px; margin:auto;">
                                        <h:outputText value="#{otherUserHome.selectedEvent.description}"/>
                                    </p:scrollPanel>
                                </p>
                                <p>
                                    <h:outputLabel value="From: " styleClass="bold-label"/>
                                    <h:outputText value="#{otherUserHome.selectedEvent.startingDate}">
                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
                                    </h:outputText>
                                </p>

                                <p>
                                    <h:outputLabel value="To: " styleClass="bold-label"/>
                                    <h:outputText value="#{otherUserHome.selectedEvent.endingTime}">
                                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
                                    </h:outputText>
                                </p>
                                <p>
                                    <h:outputLabel value="Creator: " styleClass="bold-label"/>   
                                    <h:outputText value="#{otherUserHome.selectedEvent.creator.name} #{otherUserHome.selectedEvent.creator.surname}"/>
                                </p>

                                <p>
                                    <h:outputLabel value="#{otherUserHome.selectedEvent.visibility ? 'Event is public' : 'Event is private' }"  styleClass="bold-label"/>
                                </p>
                                <p>
                                    <h:outputLabel value="#{otherUserHome.selectedEvent.outdoor ? 'Event is ourdoor' : 'Event is indoor' }"  styleClass="bold-label"/>
                                </p>

                                <p>
                                    <c:if test="#{not empty otherUserHome.selectedEvent.location}" >
                                        <h:outputLabel value="Location: " styleClass="bold-label" />
                                        <h:outputText value="#{otherUserHome.selectedEvent.location}"/>
                                    </c:if>
                                </p>
                                <p>
                                    <c:if test="#{not empty otherUserHome.selectedEvent.weatherInformationCollection}">
                                        <h:outputLabel value="Weather: " styleClass="bold-label"/>
                                        <p:dataList value="#{otherUserHome.selectedEvent.weatherInformationCollection}" var="weather" emptyMessage="No weather Information">
                                            <h:outputText value="#{weather.details}"/>
                                        </p:dataList>
                                    </c:if>
                                </p>


                                <p>
                                    <p:outputLabel value="Accepted Invitation" styleClass="bold-label"/>
                                    <p:dataList paginator="true" rows="5" value="#{otherUserHome.selectedEvent.calendarCollection}" var="calendar" type="unordered" paginatorTemplate=" {PreviousPageLink} {CurrentPageReport} {NextPageLink}"
                                                paginatorPosition="top">
                                        <h:outputText value="#{calendar.user.email}" rendered="#{calenadar.user.email ne otherUserHome.selectedEvent.creator.email }"/>
                                    </p:dataList>
                                </p>
                                <p>
                                    <p:outputLabel value="Not Yet Accepted" styleClass="bold-label"/>
                                    <p:dataList paginator="true" rows="5" value="#{notificationBean.getInvitationNotificationForEvent(otherUserHome.selectedEvent)}" var="notification" type="unordered" paginatorTemplate=" {PreviousPageLink} {CurrentPageReport} {NextPageLink}"
                                                paginatorPosition="top" emptyMessage="No user invited" >
                                        <h:outputText value="#{notificationBean.getUserNameFromNotification(notification)}" />

                                    </p:dataList>

                                </p>
                              


                            </p:outputPanel>
                        </c:if>
                        <c:if test="#{not empty otherUserHome.selectedEvent and not otherUserHome.selectedEvent.visibility}">
                            <h:outputText value="Event is private no detail"/>
                        </c:if>

                    </p:dialog>
                </h:form>

            </ui:define>

        </ui:composition>


    </body>

</html>
